/**
 * OLED
 * ---------------------128*64 SSD1306--------------------
 *----------0............................................127
 * p0(00~07)|--------------------------------------------|
 * p1(08~15)|--------------------------------------------|
 * p2(16~23)|--------------------------------------------|
 * p3(24~31)|--------------------------------------------|
 * p4(32~39)|--------------------------------------------|
 * p5(40~47)|--------------------------------------------|
 * p6(48~55)|--------------------------------------------|
 * p7(56~63)|--------------------------------------------|
 *--------------以(8*16)方式显示byte;能显示16byte*4行------
 *--------------以(16*16)方式显示汉字;能显示8*4行-----------
 */

#ifndef __OLED12864_H
#define __OLED12864_H
#include "sys.h"
#include "SimulateI2C.h"

#define OLED_ADDRESS 0x78

#define OLED_WIDTH 128
#define OLED_HEIGHT 64

#define OLED_FontWidth 8
#define OLED_FontHeight 16

typedef enum
{
    OLED_MemoryMode_H_ADDR = 0,    // 水平地址模式
    OLED_MemoryMode_V_ADDR = 1,    // 垂直地址模式
    OLED_MemoryMode_PAGE_ADDR = 2, // 页地址模式
} OLED_MemoryModeEnum;             // 内存地址模式

typedef enum
{
    OLED_VoltageLevel_0 = 0x00,
    OLED_VoltageLevel_1 = 0x20,
    OLED_VoltageLevel_2 = 0x30,
} OLED_VoltageLevelEnum; // 电压等级

typedef enum
{
    OLED_ComPinsMode_SEQ = 0,
    OLED_ComPinsMode_ALT = 1,
} OLED_ComPinsModeEnum; // COM引脚属性

typedef enum
{
    OLED_ComReMapState_NOREMAP = 0,
    OLED_ComReMapState_REMAP = 1,
} OLED_ComReMapStateEnum; // COM引脚翻转

typedef enum
{
    OLED_ChargePumpState_DISABLE = 0,
    OLED_ChargePumpState_ENABLE = 1,
} OLED_ChargePumpStateEnum; // 打开或者关闭电荷泵

void OLED_WriteCmd(uint8_t cmd);
void OLED_WriteData(uint8_t dat);
void OLED_WriteDataBuffer(uint8_t *pBuf, uint16_t Size);

// 打开显示或者关闭显示
void OLED_Display_ON(void);
void OLED_Display_OFF(void);

// 行地址翻转或者不翻转
void OLED_SEG_REMAP(void);
void OLED_SEG_NOREMAP(void);

// COM引脚扫描方向正常扫描或者逆扫描
void OLED_SCAN_NORMAL(void);
void OLED_SCAN_REMAP(void);

// 阴码显示或者阳码显示
void OLED_Display_NORMAL(void);
void OLED_Display_INVERSE(void);

void OLED_Init(void);
void OLED_SetContrastValue(uint8_t value);
void OLED_SetMuxRatio(uint8_t ratio);
void OLED_SetOffset(uint8_t offset);
void OLED_SetDCLK_Freq(uint8_t div, uint8_t freq);
void OLED_SetComPins(OLED_ComPinsModeEnum mode, OLED_ComReMapStateEnum state);
void OLED_SetChargePump(OLED_ChargePumpStateEnum state);
void OLED_SetMemoryMode(OLED_MemoryModeEnum mode);

void OLED_SetPageColAddr(uint8_t addr);
void OLED_SetPageAddr(uint8_t addr);
void OLED_SetStartLine(uint8_t line);
void OLED_SetPosition(uint8_t page, uint8_t col);

void OLED_Clear(void);
void OLED_PutChar8X16(uint8_t page, uint8_t col, char c);
void OLED_PutZH16X16(uint8_t page, uint8_t col, uint8_t index);
void OLED_PrintStr8X16(uint8_t page, uint8_t col, char *str);

#endif
